# encoding: UTF-8

"""
获取/config/的绝对路径
"""
import os

TQ_INSTRUMENTS = 'tq_instruments'
TQ_FUTURES = 'tq_futures'
TQ_MAIN_INSTRUMENTS = 'tq_main_instruments'
HF_PRODUCTS = 'hf_product'
HF_INSTRUMENTS = 'hf_instrument_info'
HF_FUTURES = 'hf_future_info'
config_path = os.path.split(os.path.realpath(__file__))[0]

data_path = os.path.join(config_path, '../ds/data')
sqlite_db_path = os.path.join(data_path, 'sqlite')
csv_file_path = os.path.join(data_path, 'csv')
pickle_file_path = os.path.join(data_path, 'pkl')
hdf_file_path = os.path.join(data_path, 'hdf')
yml_file_path = os.path.join(data_path, 'yml')
json_file_path = os.path.join(data_path, 'json')
api_path = os.path.join(config_path, 'api')
app_path = os.path.join(config_path, 'app')
gateway_path = os.path.join(config_path, 'gateway')
pyqt_ui_path = os.path.join(config_path, 'ui')

ctp_path = os.path.join(config_path, '../ctp')
strategy_path = os.path.join(config_path, '../ss/strategy')
indicator_path = os.path.join(config_path, '../ss/indicator')
yml_file = {'tq_instruments': os.path.join(yml_file_path, 'tq_instruments.yml'),
            'tq_futures': os.path.join(yml_file_path, 'tq_futures.yml'),
            'tq_main_instruments': os.path.join(yml_file_path, 'tq_main_instruments.yml'), }
sys_path_setting = {
    'config_path': config_path,
    'data_path': data_path,
    'sqlite_db_path': sqlite_db_path,
    'csv_file_path': csv_file_path,
    'pickle_file_path': pickle_file_path,
    'json_file_path': json_file_path,
    'ylm_file_path': yml_file_path,
    'hdf_file_path': hdf_file_path,
    'pyqt_ui_path': pyqt_ui_path,

    'strategy_path': strategy_path,
    'indicator_path': indicator_path
}
sqlite_account = os.path.join(sqlite_db_path, 'account.db')
sqlite_config = os.path.join(sqlite_db_path, 'config.db')
sqlite_market = os.path.join(sqlite_db_path, 'market.db')
sqlite_tick = os.path.join(sqlite_db_path, 'tick.db')
sqlite_bar = os.path.join(sqlite_db_path, 'bar.db')
sqlite_ctp_tick = os.path.join(sqlite_db_path, 'ctp_tick.db')
sqlite_ctp_bar = os.path.join(sqlite_db_path, 'ctp_bar.db')
sqlite_quote = os.path.join(sqlite_db_path, 'quote.db')
sqlite_day = os.path.join(sqlite_db_path, 'day.db')
sqlite_stra = os.path.join(sqlite_db_path, 'strategy.db')
sqlite_stra_rslt = os.path.join(sqlite_db_path, 'stra_rslt.db')
sqlite_stra_conf = os.path.join(sqlite_db_path, 'stra_conf.db')
# BQ 的系统目录
BQ_HOME = os.path.join(config_path, '..')


def init_data_dir():
    if not os.path.isdir(data_path):
        os.system(f'mkdir {data_path}')
    if not os.path.isdir(sqlite_db_path):
        os.system(f'mkdir {sqlite_db_path}')
    if not os.path.isdir(csv_file_path):
        os.system(f'mkdir {csv_file_path}')
    if not os.path.isdir(pickle_file_path):
        os.system(f'mkdir {pickle_file_path}')
    if not os.path.isdir(hdf_file_path):
        os.system(f'mkdir {hdf_file_path}')
    if not os.path.isdir(yml_file_path):
        os.system(f'mkdir {yml_file_path}')
    if not os.path.isdir(strategy_path):
        os.system(f'mkdir {strategy_path}')
    if not os.path.isdir(indicator_path):
        os.system(f'mkdir {indicator_path}')
    if not os.path.isdir(json_file_path):
        os.system(f'mkdir {json_file_path}')


if __name__ == '__main__':
    init_data_dir()
